package com.cxl.demo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class FileChannelDemo {
    public static void main(String[] args) throws FileNotFoundException {
        RandomAccessFile file = new RandomAccessFile("/Users/chenlei/IdeaProjects/demo/test.txt","rw");
        FileChannel fileChannel = file.getChannel();

        try {
            fileChannel.lock();
            Thread.sleep(30*1000);
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
